/**
 * 存储localStorage
 */
export const setStorage = (name, content) => {
	if (!name) return
	if (typeof content !== 'string') {
		content = JSON.stringify(content)
	}
	window.localStorage.setItem(name, content)
}

/**
 * 获取localStorage
 */
export const getStorage = name => {
	if (!name) return null
    try {
        return JSON.parse(window.localStorage.getItem(name))
    } catch (e) {
        return window.localStorage.getItem(name)
    }
}

/**
 * 删除localStorage
 */
export const removeStorage = name => {
	if (!name) return
	window.localStorage.removeItem(name)
}

/**
 * 清除所有localStorage
 */
export const clearStorage = () => {
	window.localStorage.clear()
}
